<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>CSS 文本超出提示效果</title>
</head>

<style>
    p{
        margin: 0;
    }
    .con{
        font-size: 14px;
        color: #666;
        width: 600px;
        margin: 50px auto;
        border-radius: 8px;
        padding: 15px ;
        overflow: hidden;
        resize: horizontal;
        box-shadow: 20px 20px 60px #bebebe,
        -20px -20px 60px #ffffff;
    }
    .wrap{
        position: relative;
        line-height: 2;
        height: 2em;
        padding: 0 10px;
        overflow: hidden;
        background: #fff;
        margin: 5px 0;
    }
    .wrap:nth-child(odd){
        background: #f5f5f5;
    }
    .title{
        display: block;
        white-space: nowrap;
        text-overflow: ellipsis;
        background-color: inherit;
        overflow: hidden;
        position: relative;
        top: -4em;
    }
    .txt{
        display: block;
        max-height: 4em;
    }

    .title:hover{
        display: inline-block;
        animation: move 10s .3s linear infinite;
    }
    .title::after{
        content: attr(data-title);
        padding: 0 5em;
    }

    @keyframes move {
        to {
            transform: translate3d(-50%, 0, 0);
        }
    }
</style>

<body>

<ul class="con">
    <li class="wrap">
        <span class="txt">CSS 实现优惠券的技巧 - 2021-03-26</span>
        <span class="title" data-title="CSS 实现优惠券的技巧 - 2021-03-26">CSS 实现优惠券的技巧 - 2021-03-26</span>
    </li>
    <li class="wrap">
        <span class="txt">CSS 测试标题，这是一个稍微有点长的标题，超出一行以后才会有title提示，标题是 实现优惠券的技巧 - 2021-03-26</span>
        <span class="title" data-title="CSS 测试标题，这是一个稍微有点长的标题，超出一行以后才会有title提示，标题是 实现优惠券的技巧 - 2021-03-26">CSS 测试标题，这是一个稍微有点长的标题，超出一行以后才会有title提示，标题是 实现优惠券的技巧 - 2021-03-26</span>
    </li>
    <li class="wrap">
        <span class="txt">CSS 拖拽?</span>
        <span class="title" data-title="CSS 拖拽?">CSS 拖拽?</span>
    </li>
    <li class="wrap">
        <span class="txt">CSS 文本超出自动显示title</span>
        <span class="title" data-title="CSS 文本超出自动显示title">CSS 文本超出自动显示title</span>
    </li>
</ul>


</body>
</html>